<!DOCTYPE html>
<html lang="zh-cn" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>订单信息详情</title>
    <link rel="stylesheet" href="../../static/layui/css/layui.css">
    <link rel="stylesheet" href="../../static/css/style.css">
    <style>
        .layui-form-pane .layui-form-label{
            width: 125px;
        }
    </style>
</head>
<body style="background-color: seashell;">
    <div id="main">
        <form class="layui-form layui-form-pane m-form">
            <fieldset class="layui-elem-field layui-field-title">
                <legend style="font-size: 10px;color: blue;font-family: monospace;">
                    <p th:text="'下单日期:'+${order.getDatedown()}+'&nbsp;&nbsp;'+'发货日期:'+${order.getDateout()}"></p>
                </legend>
            </fieldset>
            <fieldset class="layui-elem-field layui-field-title" style="width: 99%;">
                <legend style="font-size: 16px;">寄件人信息</legend>
            </fieldset>
            <div class="layui-form-item">
                <input type="hidden" name="id" th:value="${order.getId()}">
                <div class="layui-inline">
                    <label class="layui-form-label">真实姓名<span style="color: red;">*</span></label>
                    <div class="layui-input-inline">
                        <p class="dtl" th:text="${order.getSendername()}"></p>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">联系电话<span style="color: red;">*</span></label>
                    <div class="layui-input-inline">
                        <p class="dtl" th:text="${order.getSenderphone()}"></p>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">寄件地址</label>
                <div class="layui-input-inline">
                    <p class="dtl" th:text="${s[0]+','+s[1]+','+s[2]}"></p>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">取件地址</label>
                <div class="layui-input-inline">
                    <p class="dtl dtl-w" th:text="${q[0]+','+q[1]+','+q[2]+','+order.getQujianaddrdtl()}"></p>
                </div>
            </div>
            <fieldset class="layui-elem-field layui-field-title" style="width: 99%;">
                <legend style="font-size: 16px;">收件人信息</legend>
            </fieldset>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">收件人姓名<span style="color: red;">*</span></label>
                    <div class="layui-input-inline">
                        <p class="dtl" th:text="${order.getrname()}"></p>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">收件人电话<span style="color: red;">*</span></label>
                    <div class="layui-input-inline">
                        <p class="dtl" th:text="${order.getRephone()}"></p>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">收件人地址</label>
                <div class="layui-input-inline">
                    <p class="dtl dtl-w" th:text="${r[0]+','+r[1]+','+r[2]+','+order.getReaddrdtl()}"></p>
                </div>
            </div>
            <fieldset class="layui-elem-field layui-field-title" style="width: 99%;">
                <legend style="font-size: 16px;">物品信息</legend>
            </fieldset>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">物品名称<span style="color: red;">*</span></label>
                    <div class="layui-input-inline">
                        <p class="dtl" th:text="${order.getHwmc()}"></p>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">物品重量(kg)<span style="color: red;">*</span></label>
                    <div class="layui-input-inline">
                        <p class="dtl" th:text="${order.getHwzl()}"></p>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">订单类别<span style="color: red;">*</span></label>
                    <div class="layui-input-inline">
                        <input th:checked="${order.getOrderclass()=='普通'?'checked':'false'}" type="radio" name="orderclass" value="普通" title="普通" lay-verify="required" checked class="layui-input" readonly>
                        <input th:checked="${order.getOrderclass()=='加急'?'checked':'false'}" type="radio" name="orderclass" value="加急" title="加急" lay-verify="required" class="layui-input" readonly>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">注意事项<span style="color: red;">*</span></label>
                    <div class="layui-input-inline">
                        <p class="dtl" th:text="${order.getAttention()}"></p>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">总费用<span style="color: red;">*</span></label>
                    <div class="layui-input-inline">
                        <p class="dtl" th:text="${order.getPrice()}"></p>
                    </div>
                </div>
            </div>

            <!--button-->
            <div class="layui-form-item" style="float: right;margin: 15px 30px;">
                <button th:text="${order.getOrderstatus()}" class="layui-btn layui-btn-disabled" disabled></button>
                <button id="gen" type="reset" class="layui-btn" style="margin-left: -4px;"></button>
            </div>
        </form>
    </div>
</body>
<script src="../../static/js/jquery-3.4.1.js"></script>
<script src="../../static/layui/layui.js"></script>
<script src="../../static/js/order/style.js"></script>
<script src="../../static/js/order/address.js"></script>
<script type="text/javascript" th:inline="javascript">
    var order=[[${order}]];
    window.onload=function (ev) {
        console.log(order);
        if (order.orderstatus=='已审核'){
            $("#gen").css('background-color','rgb(201, 201, 201)');
            $("#gen").attr('disabled','disabled');
            $("#gen").text('订单已生成');
        }else if (order.orderstatus=='未通过'){
            $("#gen").css('background-color','rgb(9, 108, 98)');
            $("#gen").text('生成订单');
        }
    }
    $("#gen").click(function () {
        $.ajax({
            type:'post',
            url:'/order/generateOrder?id='+order.id,
            success:function (result) {
                if (result=='success'){
                    layer.alert('订单已生成！',function (index) {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    });
                }else if (result=='fail'){
                    layer.alert('生成失败！');
                }
            },
            error:function (error) {
                layer.msg('error');
            }
        });
    });
</script>
</html>